package blog.controller;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

import blog.ConstString;
import blog.SysRuntime;
import blog.gui.IBaseGui;

public class CommandManager implements CommandListener {
	
	private static CommandManager _instance;
	public static synchronized CommandManager getInstance()
	{
		if ( _instance==null )
		{
			_instance = new CommandManager();
		}
		return _instance;
	}
	
	private CommandManager()
	{
		
	}

	public void commandAction(Command cmd, Displayable screen) {
		IBaseGui gui = (IBaseGui) screen;
		String cmdLable = cmd.getLabel();
		switch( gui.getIdentify() )
		{
			case ConstGui.GUI_ID_VERIFY_USER:
			{
				if ( cmdLable.equals(ConstString.CMD_EXIT) )
				{
					SysRuntime.midlet.destroyApp(true);
				}
				else if ( cmdLable.equals(ConstString.CMD_CONFIRM) )
				{
					SysRuntime.actionManager.addAction(gui, ConstAction.ACT_VERIFY_USER );
				}
				break;
			}
		}
	}

}
